﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sasc.PV.BLL;
using Sasc.PV.DAL;

namespace Sasc.PV.Web.Admin.SystemManage
{
    public partial class TreeListModify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                ERPTreeList Model = new ERPTreeList();
                Model = Model.GetModel(int.Parse(Request.QueryString["ID"].ToString()));
                this.txtTextStr.Text = Model.TextStr.ToString();
                this.txtImageUrlStr.Text = Model.ImageUrlStr.ToString();
                this.txtValueStr.Text = Model.ValueStr.ToString();
                this.txtNavigateUrlStr.Text = Model.NavigateUrlStr.ToString();
                this.txtTarget.Text = Model.Target.ToString();
                this.txtParentID.Text = Model.ParentID.ToString();
                this.txtQuanXianList.Text = Model.QuanXianList.ToString();
                this.txtPaiXuStr.Text = Model.PaiXuStr.ToString();
            }
        }
        //修改
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            if (PublicMethod.IFExists("ValueStr", "ERPTreeList", int.Parse(Request.QueryString["ID"].ToString()), this.txtValueStr.Text) == true)
            {
                ERPTreeList Model = new ERPTreeList();

                Model.ID = int.Parse(Request.QueryString["ID"].ToString());
                Model.TextStr = this.txtTextStr.Text.ToString();
                Model.ImageUrlStr = this.txtImageUrlStr.Text.ToString();
                Model.ValueStr = this.txtValueStr.Text.ToString();
                Model.NavigateUrlStr = this.txtNavigateUrlStr.Text.ToString();
                Model.Target = this.txtTarget.Text.ToString();
                Model.ParentID = int.Parse(this.txtParentID.Text);
                Model.QuanXianList = this.txtQuanXianList.Text.ToString();
                Model.PaiXuStr = int.Parse(this.txtPaiXuStr.Text);

                Model.Update();

                //写系统日志
                ERPRiZhi MyRiZhi = new ERPRiZhi();
                MyRiZhi.UserName = PublicMethod.GetSessionValue("UserName");
                MyRiZhi.DoSomething = "用户修改菜单管理信息(" + this.txtTextStr.Text + ")";
                MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
                MyRiZhi.Add();

                MessageBox.ShowAndRedirect(this, "菜单管理信息修改成功！", "TreeList.aspx");
            }
            else
            {
                MessageBox.Show(this, "当前指定的后台数值已经存在，为了保持唯一性，请重新指定！");
            }
        }
    }
}